package ooday04;

public class ArraysTest {
    public static void main(String[] args) {
        /*
        Dog[] dogs=new Dog[3];
        dogs[0]=new Dog("小黑",1,"黑色");
        dogs[1]=new Dog("小白",2,"白色");
        dogs[2]=new Dog("小灰",3,"灰色");
        for(int i=0;i<dogs.length;i++) {
            System.out.println(dogs[i].name);
            dogs[i].eat();
            dogs[i].drink();
        }

        Fish[] fish=new Fish[2];
        fish[0]=new Fish("小金",1,"金色");
        fish[1]=new Fish("小花",2,"花色");
        for(int i=0;i< fish.length;i++){
            fish[i].eat();
            fish[i].drink();
        }

         */

        Animals[] animals = new Animals[4];
        animals[0] = new Dog("小黑", 1, "黑色");
        animals[1] = new Dog("小白", 2, "白色");
        animals[2] = new Fish("小金", 1, "金色");
        animals[3] = new Fish("小花", 2, "花色");
        for (int i = 0; i < animals.length; i++) {
            animals[i].eat();
            animals[i].drink();
            if (animals[i] instanceof Dog) {
                Dog dog = (Dog) (animals[i]);
                dog.lookHome();
            }
            if (animals[i] instanceof Fish) {
                Fish fish = (Fish) (animals[i]);
            }
            if (animals[i] instanceof Swim) {
                Swim s = (Swim) animals[i];
                s.swim();
            }


        }

        /*
        Master master=new Master();
        Dog dog=new Dog("小黑",1,"黑色");
        Fish fish=new Fish("小金",1,"金色");
        master.feed(dog);
        master.feed(fish);
         */
    }
}